package com.ksyun.alert.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ksyun.alert.entity.base.BaseDO;
import lombok.*;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 告警规则表实体类
 * @author hantou
 * @date 2024-05-01
 */
@Data
@NoArgsConstructor
@Builder
@AllArgsConstructor
@EqualsAndHashCode(callSuper = false)
@TableName("tb_alert_rules")
public class AlertRulesDO extends BaseDO implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 规则id
     */
    @TableId(type = IdType.AUTO)
    private Integer id;

    /**
     * 规则类型： 0: 实时计算 1: 定时计算
     */
    @Max(value = 1, message = "规则类型最大支持1")
    @Min(value = 0, message = "规则类型最小支持0")
    private int type;

    /**
     * 规则名称
     */
    @NotNull(message = "规则名称不能为空")
    private String ruleName;

    /**
     * 指标，多个指标使用，分隔
     */
    @NotNull(message = "规则指标不能为空")
    private String metric;

    /**
     * 描述
     */
    private String description;

    /**
     * 规则计算数学表达式
     */
    @NotNull(message = "规则计算数学表达式不能为空")
    private String expression;

    /**
     * 比较运算符：用于比较计算结果和阈值
     */
    @NotNull(message = "规则比较运算符不能为空")
    private String comparison;

    /**
     * 阈值
     */
    @NotNull(message = "规则阈值不能为空")
    private Float threshold;

    /**
     * 告警级别，越大告警级别越高
     */
    @NotNull(message = "规则告警级别不能为空")
    private int severity;
}
